/*轮播信息*/
var mySwiper = new Swiper ('.swiper-container', {
    direction: 'vertical', // 垂直切换选项
    loop: true, // 循环模式选项

    autoplay:true,//等同于以下设置
    /*autoplay: {
     delay: 3000,
     stopOnLastSlide: false,
     disableOnInteraction: true,
     },*/
})


$(".btn,.mask").click(function(){
    $(".mask").toggle();
});

$(".btn1,.mask-1").click(function(){
    $(".mask-1").toggle();
});

/*奖品组*/
var img = [
    "../img/awards1.png",
    "../img/awards1.png",
    "../img/awards1.png",
    "../img/awards2.png",
    "../img/awards2.png",
    "../img/awards2.png",
    "../img/awards3.png",
    "../img/awards4.png",
    "../img/awards5.png",
];

var ram = randomNum(0,8);


/*开奖*/
function opt(r){

    //console.log(r);
    var a = r * 100;

    if(a>=40){


        if(ram === 3 || ram === 4 || ram === 5){
            alert("恭喜！你获得了5元现金红包！");
        }
        else if (ram === 6){
            alert("恭喜！你获得100元基金理财劵！");
        }
        else if (ram === 7){
            alert("恭喜！你获得300元基金理财劵！");
        }
        else if (ram === 8){
            alert("恭喜！ 你获得500元基金理财劵！");
        }
        else{
            alert("没有中奖，明天再来刮刮吧~");
        }
        return true;
    }
}


//生成从minNum到maxNum的随机数
function randomNum(minNum,maxNum){
    switch(arguments.length){
        case 1:
            return parseInt(Math.random()*minNum+1,10);
            break;
        case 2:
            return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
            break;
        default:
            return 0;
            break;
    }
}

var width=$('.bg').width()*0.86;
var height=$('.bg').height()*0.63;


var canvas = ScratchMod({
    'container':$("#scratch_mod_container"), //目标容器
    'bgImgSrc':img[ram], //背景图
    'color':"#b0adb1", //蒙版颜色（有imgSrc的情况下该属性无效）
    'width':width, //宽度
    'height':height, //高度
    'eraseRadius':40, //擦除笔的半径(有penImgSrc的情况下无效)
    'sampleStep':10, //获取擦除百分百时的精度（数字越大精度越小）
    'sampleCD':500, //获取擦除百分百的时间间隔
    'sampleCallback':opt, //获取擦除百分百的回调函数（返回true后不再回调）,回调的第一个入参为擦除百分百
});

$(canvas).css({
    backgroundSize:"cover",//奖品图的大小
    backgroundPosition:"center"//奖品图居中
});



